
function isWX() {
    return window['wx'] && !window['tt'] && !window['qq']
}

if (isWX()) {

    class Parser {
        constructor() {
            this._sdk = window['wx']
        }

        parse() {
            let shareAppMessage = this._sdk.shareAppMessage
            if (this._sdk.onShow) {
                this._sdk.onShow(() => {
                    this.backGame()
                })
            }
            this._sdk.shareAppMessage = function (obj) {
                if (this._sdk.shareAppMessage) {
                    this._param = obj
                    this._sdk.shareAppMessage(obj)
                    this.time = Date.now()
                }
            }
        }
        backGame() {
            if (this._param) {
                let disTime = Date.now() - this.time
                if (disTime >= 3000) {
                    if (this._param.success) {
                        this._param.success()
                    }
                } else {
                    if (this._param.fail) {
                        this._param.fail()
                    }
                }
                this._param = null
            }
        }
    }

    new Parser().parse();

}